home *** CD-ROM | disk | FTP | other *** search
/ Best of Shareware / Best of PC Windows Shareware 1.0 - Wayzata Technology (7111) (1993).iso / mac / DOS / CAD_CAM / WCEDT202 / COMPILE.LSP next >
Text File  |  1992-08-29  |  11KB  |  343 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;;;
  4. ;;; ATTENTION:  FOR ADS - C programmers ONLY!
  5. ;;;
  6. ;;;
  7. ;;;
  8. ;;; This is a set of AutoLISP routines which will help you to design
  9. ;;; quick and painless ADS applications WITHIN AutoCAD. Currently, there
  10. ;;; is no way of implementing a debugger with this method, however, debuggers
  11. ;;; should be used sparingly.
  12. ;;; 
  13. ;;; 
  14. ;;; SPECIAL IMPORTANT INFORMATION
  15. ;;; If you are using a real mode compiler you may be able to avoid this step.
  16. ;;;    
  17. ;;;    You will need approximately 10 megs of memory to be able to run 
  18. ;;;    a 386 compiler out of AutoCAD.
  19. ;;;
  20. ;;;    Use a memory manager to create expanded memory for ALOT or ALL of your
  21. ;;;    memory.
  22. ;;;          Example line of config.sys
  23. ;;;                        ********   
  24. ;;;    DEVICE=C:\QEMM\QEMM386.SYS RAM ROM AROM=C800-CFFF
  25. ;;;                        ********   
  26. ;;;    
  27. ;;;    In order to run protected mode applications from within AutoCAD it is
  28. ;;;    necessary that you configure AutoCAD to leave some room to work with.
  29. ;;;    Use maxvcpi switch to allow plenty of extra space for your 386 linker
  30. ;;;    and/or 386 compiler.  Use intmap 08h.
  31. ;;;    
  32. ;;;    Create a batch file and include the following lines:
  33. ;;;                        ********
  34. ;;;    cfig386 acad -clear -swapchk OFF -minswfsize 400000 -swapdefdisk
  35. ;;;    cfig386 acad -intmap 08h -vscan 20000 -maxvcpi 5000000 -swapdir C:\SWAP
  36. ;;;                        ********
  37. ;;;    
  38. ;;;    Run the batch file to reconfigure AutoCAD.
  39. ;;;    
  40. ;;;    Note:  Depending upon your system and available memory, you may have
  41. ;;;       to play with these values a bit to get the correct results.
  42. ;;; 
  43. ;;; Upon loading this file, the following functions are defined:
  44. ;;; 
  45. ;;;    C:RUN   -   Used as an alternative method <other than internal calls>
  46. ;;;                run/test a function.
  47. ;;; 
  48. ;;;    COMPILE -   This function will 1st check to see if the current file
  49. ;;;                has a 'C' extension on it.  If so, then the function will
  50. ;;;                call the CPILE command <as specified in ACAD.PGP> to 
  51. ;;;                compile current 'C' module.  All output from the compiler 
  52. ;;;                is sent to file filename.ERR.  A subsequent view of the 
  53. ;;;                error file then takes place.  If you are using the 
  54. ;;;                MetaWare compiler, you may at this point high light the 
  55. ;;;                error line <Numbers only> and be placed strategically in 
  56. ;;;                your source file at the error or warning listed at that 
  57. ;;;                point.
  58. ;;; 
  59. ;;;    CYCLE   -   This calls the COMPILE, LINK and RELOAD functions one
  60. ;;;                at a time, prompting for continuance at each phase.
  61. ;;; 
  62. ;;;    LINK    -   This will call the linker <as specified in ACAD.PGP> to
  63. ;;;                link up the application.  Currently, the link call uses
  64. ;;;                a response file for linking up the app. The name of the
  65. ;;;                response file is assumed to be LINK.RSP.
  66. ;;;    REMOUT  -   Simple function to add wrapping comment marks to the 
  67. ;;;                current line.
  68. ;;;                Example:
  69. ;;;                   i = 1;
  70. ;;;                   becomes
  71. ;;;                   /*  i = 1;   */
  72. ;;; 
  73. ;;;    UNREM   -   Simple function to remove wrapping comment marks from the
  74. ;;;                current line.
  75. ;;;                Example:
  76. ;;;                   /*  i = 1;   */
  77. ;;;                   becomes
  78. ;;;                   i = 1;
  79. ;;; 
  80. ;;; 
  81. ;;; The linking process requires you to include a command
  82. ;;; to your acad.pgp to call the linker.  The ACAD command name
  83. ;;; used in COMPILE.LSP is LINKER.
  84. ;;; 
  85. ;;; Example, using Pharlaps linker:
  86. ;;; 
  87. ;;;    LINKER,386LINK, 500000,*,0
  88. ;;; 
  89. ;;; The compiling process requires you to include a command
  90. ;;; to your acad.pgp to call the compiler.  The ACAD command name
  91. ;;; used in COMPILE.LSP is CPILE.
  92. ;;; 
  93. ;;; Example, using MetaWares compiler/driver:
  94. ;;;    CPILE,HC386,   500000,*,0
  95. ;;; 
  96. ;;; 
  97. ;;; To setup, either use the setqs calls at the top of the
  98. ;;; file, or run the c:cset program to set the string variables.
  99. ;;; These 2 variables are
  100. ;;; 
  101. ;;;    loadfile  -  This is the file which is to be unload and reloaded
  102. ;;;       upon each working cycle.  Typically, during ADS development, the
  103. ;;;       application must be unloaded and reload again using AutoLISPs
  104. ;;;       (Xunload loadfile) and (Xload loadfile) functions.
  105. ;;; 
  106. ;;;    runname   -  This is the function name which will be tested upon
  107. ;;;       for running as well as checking to verify whether the EXP has
  108. ;;;       been loaded or unloaded.  If, for example, your were writing an
  109. ;;;       application to replace AutoCADs circle command, you would most
  110. ;;;       likely call the command C:CIRCLE.
  111. ;;; 
  112. ;;; Modify this file as you see fit.
  113. ;;; 
  114.  
  115. (if(not wcedit)
  116.    (progn
  117.       (princ "WCEdit Version 2.0 must first be loaded\n")
  118.       (quit)
  119.    )
  120. )
  121.  
  122. ;;; You may use these lines, or run CSET below.                  ;;;
  123. (setq loadfile nil)  
  124. (setq runname  nil)
  125.  
  126. ;;; Alter func names and default key strokes to suite your needs ;;;
  127. (wcconfig "c:run"    (wc_gkey "Ctrl R")   "Run the application")
  128. (wcconfig "cycle"    (wc_gkey "Alt F10")  "Compile,Link,Reload and Run")
  129. (wcconfig "link"     (wc_gkey "Ctrl Q")   "Link the application")
  130. (wcconfig "compile"  (WC_gkey "Alt F10")  "Compile this module")
  131. (wcconfig "unrem"    (wc_gkey "Alt .")    "Un-remout '     '")
  132. (wcconfig "remout"   (wc_gkey "Alt /")    "Remout line using '     '")
  133.  
  134. (defun c:cset()
  135.    (setq loadfile(wc_fetch_string 
  136.          ""
  137.          " Escape to quit "  
  138.    " Enter the loading filename (EXP) without extension " ))
  139.    (if loadfile
  140.       (progn
  141.          (setq runname(wc_fetch_string 
  142.                ""
  143.                " Escape to quit " 
  144.          " Enter the Lisp calling name of function to test " ))
  145.          (if runname
  146.             (wc_message "Setup is complete." 0)
  147.          )
  148.       )
  149.    )
  150. )
  151.  
  152. (defun c:cls()
  153.    (textscr)
  154.    (wc_cls)
  155.    (prin1)
  156. )
  157.  
  158. (defun c:rel(/ mode)
  159.    (if (eval runname)
  160.       (xunload loadfile)
  161.    )
  162.    (xload loadfile)
  163.    (prin1)
  164. )
  165.  
  166. (defun c:run(/ mode)
  167.    (setq mode(nth 19 (wc_statistics)))
  168.    (if (eval runname)
  169.       (progn
  170.          (setvar "cmdecho" 0)
  171.          (wc_setmode_now 0)
  172.          (eval(list runname))
  173.          (if(/= mode 25)
  174.             (wc_setmode_now 1)
  175.          )
  176.          (wc_beep 5000.0 20000.0)
  177.          (wc_print "* Last run complete *" )
  178.          (prin1)
  179.       )
  180.    )
  181. )
  182.  
  183. (defun unrem(/ owait found)
  184.    (wc_silent 1)
  185.    (wc_trigger "BEGIN_LINE_MARK")
  186.    (wc_trigger "END_MARK")
  187.    (setq x(wc_col -1.0))
  188.    (setq y(wc_row -1.0))
  189.    (wc_col 0.0)
  190.    (wc_find_replace "/*" "" 1)
  191.    (wc_find_replace "*/" "" 1)
  192.    (wc_trigger "erase_marks")
  193.    (wc_clean_right)
  194.    (wc_col x)
  195.    (wc_row y)
  196.    (wc_col 0.0)
  197.    (wc_move_down 1.0)
  198.    (wc_silent 0)
  199.    (prin1)
  200. )
  201.  
  202. (defun remout(/ owait found)
  203.    (wc_silent 1)
  204.    (wc_clean_right)
  205.    (unrem)
  206.    (wc_move_up 1.0)
  207.    (wc_col 0.0)
  208.    (setq ch(wc_get_char))
  209.    (if(= ch " ")
  210.       (setq str(wc_next_word))
  211.       (setq str "NO NEXT")
  212.    )
  213.    (if(= (type str) 'STR)
  214.       (if(> (strlen str) 0)
  215.          (progn
  216.             (wc_stuff_char "/")
  217.             (wc_move_right 1.0)
  218.             (wc_stuff_char "*")
  219.             (wc_race_end 0)
  220.             (wc_stuff_char "*")
  221.             (wc_move_right 1.0)
  222.             (wc_stuff_char "/")
  223.          )
  224.       )
  225.    )
  226.    (wc_silent 0)
  227.    (wc_col 0.0)
  228.    (wc_move_down 1.0)
  229.    (wc_refresh 0)
  230.    (prin1)
  231. )
  232.  
  233. (defun wheredot(nname / flag i len)
  234.    (setq len(strlen nname)i 1 flag 't)
  235.    (while flag
  236.       (if(= (substr nname i 1) ".")
  237.          (setq flag nil)
  238.          (setq i (+ 1 i))
  239.       )
  240.       (if (>= i len)
  241.          (setq flag nil i nil)
  242.       )
  243.    )
  244.    i
  245. )
  246.  
  247. (defun verr(name / oname)
  248.    (wc_trigger "GETERROR");
  249. )
  250.  
  251. (defun link(/ row col)
  252.    (setq row(wc_row -1.0)col(wc_col -1.0))
  253.    (wc_race_home 1)
  254.    (setvar "CMDECHO" 0)
  255.    (wc_print "Linking ... ")
  256.    (command  "linker" "@link.rsp > link.err")
  257.    (wc_view_file "link.err")
  258.    (wc_refresh 1);
  259.    (wc_print "Linking process completed.")
  260.    (prin1)
  261. )
  262.  
  263. (defun cycle(/ row col)
  264.    (setq row(wc_row -1.0)
  265.          col(wc_col -1.0))
  266.    (wc_race_home 1)
  267.    (setvar "CMDECHO" 0)
  268.    (setq _clean_ nil)
  269.    (compile)
  270.    (setq ans(wc_message "Continue with link <Y = Enter>" 0))
  271.    (if(= ans (wc_gkey "Enter"))
  272.       (progn
  273.          (link)
  274.          (setq ans(wc_message "Continue with reload <Y = Enter>" 0))
  275.          (if(= ans (wc_gkey "Enter"))
  276.             (progn
  277.                (c:rel)
  278.             )
  279.          )
  280.       )
  281.    )
  282.    (wc_print "Cycle");
  283. )
  284.  
  285. (defun compile(/ );name i leadname tail str flag ename col row)
  286.    (setvar "CMDECHO" 0)
  287.    (setq name(gcname) flag nil)
  288.    (if(setq i (wheredot name))
  289.       (progn
  290.          (setq leadname(substr name 1 (- i 1)))
  291.          (setq tail(substr name (+ 1 i) 100))
  292.          (if(and(= (type leadname)'STR)(=(type tail)'STR))
  293.             (if(= (strcase tail nil) "C")
  294.                (progn
  295.                   (wc_hard_write)
  296.                   (setq ename (strcat leadname ".err"))
  297.                   (setq str(strcat "-c " name " >" ename))
  298.                   (COMMAND  "cpile" str)
  299.                   (wc_refresh 1)
  300.                   (verr ename)
  301.                   (wc_print "COMPILE");
  302.                   (if _clean_
  303.                      (progn
  304.                         (WC_TRIGGER "QUIT")
  305.                         (C:WC)
  306.                      )
  307.                   )
  308.                   (setq flag 't)
  309.                )
  310.             )
  311.          )
  312.       )
  313.    )
  314.    (if(not flag)
  315.       (wc_message "Error in filename or invalid file type." 0)
  316.    )
  317.    (prin1)
  318. )
  319.  
  320. (defun viewerr(/ name i leadname tail str flag ename)
  321.    (setq name(gcname) flag nil)
  322.    (if(setq i (wheredot name))
  323.       (progn
  324.          (setq leadname(substr name 1 (- i 1)))
  325.          (setq tail(substr name (+ 1 i) 100))
  326.          (if(and(= (type leadname)'STR)(=(type tail)'STR))
  327.             (if(= (strcase tail nil) "C")
  328.                (progn
  329.                   (wc_hard_write)
  330.                   (setq ename (strcat leadname ".err"))
  331.                   (setq str(strcat "-c " name " >" ename))
  332.                   (if (findfile ename)
  333.                      (verr ename)
  334.                   )
  335.                )
  336.             )
  337.          )
  338.       )
  339.    )
  340. )
  341.  
  342. (prin1)
  343.